#pragma once

#include "Effect.h"

#include <D3D10.h>
#include <D3D10Effect.h>
#include <DirectXmath.h>

#include <string>

#include "Light.h"

namespace D3D10Effects
{
    class LandWavesEffect : public Effect
    {
    public:
        LandWavesEffect(ID3D10Device * const device, const std::wstring& filename);
        virtual ~LandWavesEffect();

        __forceinline void setWorldViewProjectionMatrix(DirectX::XMFLOAT4X4A& matrix);
        __forceinline void setWorldMatrix(DirectX::XMFLOAT4X4A& matrix);
        __forceinline void setTextureMatrix(DirectX::XMFLOAT4X4A& matrix);
        __forceinline void setEyePosition(DirectX::XMFLOAT3A& eyePosition);
        __forceinline void setDirectionalLight(D3D10Utils::DirectionalLight& light);
        __forceinline void setDiffuseMap(ID3D10ShaderResourceView * const diffuseMap);
        __forceinline void setSpecularMap(ID3D10ShaderResourceView * const specularMap);

        ID3D10EffectTechnique* mTechnique;
		
		ID3D10EffectMatrixVariable* mWVP;
		ID3D10EffectMatrixVariable* mWorld;
		ID3D10EffectMatrixVariable* mTextureMatrix;
		ID3D10EffectVariable* mEyePosition;
		ID3D10EffectVariable* mLight;
		ID3D10EffectShaderResourceVariable* mDiffuseMap;
		ID3D10EffectShaderResourceVariable* mSpecularMap;
    };
        
    void LandWavesEffect::setWorldViewProjectionMatrix(DirectX::XMFLOAT4X4A& matrix)
    {
        mWVP->SetMatrix(reinterpret_cast<float*> (&matrix));
    }

    void LandWavesEffect::setWorldMatrix(DirectX::XMFLOAT4X4A& matrix)
    {
        mWorld->SetMatrix(reinterpret_cast<float*> (&matrix));
    }

    void LandWavesEffect::setTextureMatrix(DirectX::XMFLOAT4X4A& matrix)
    {
        mTextureMatrix->SetMatrix(reinterpret_cast<float*> (&matrix));
    }
    
    void LandWavesEffect::setEyePosition(DirectX::XMFLOAT3A& eyePosition)
    {
        mEyePosition->SetRawValue(&eyePosition, 0, sizeof(DirectX::XMFLOAT3A));
    }

    void LandWavesEffect::setDirectionalLight(D3D10Utils::DirectionalLight& light)
    {
        mLight->SetRawValue(&light, 0, sizeof(D3D10Utils::DirectionalLight));
    }

    void LandWavesEffect::setDiffuseMap(ID3D10ShaderResourceView * const diffuseMap)
    {
        mDiffuseMap->SetResource(diffuseMap);
    }

    void LandWavesEffect::setSpecularMap(ID3D10ShaderResourceView * const specularMap)
    {
        mSpecularMap->SetResource(specularMap);
    }
}
